import { helper } from 'echarts'
import http from '../utils/http/index'

// 登录信息
// 注册
export const ApiRegister =(data:any)=>http.post('/api/v1/user/register',data)
// 注册校验
export const ApiRegisterValidate = (data:any)=>http.post('/api/v1/user/validate',data)
// 登录
export const ApiLogin = (data:any )=>http.post('/api/v1/user/login',data)
// 用户管理
// 获取所有信息用户
export const ApiUserInfoList = (pageNum:number)=>http.get(`/api/v1/user/userList?pageNum=${pageNum}`)
// 用户搜索
export const ApiGetSearchUser = (name:string)=>http.get(`/api/v1/user/searchForUser?pageIndex=1&account=${name}`)
// 用户id获取申请记录
export const ApiGetUserRecordById = (pageNum:number,id:number)=>http.get(`/api/v1/record/getByUserId?pageIndex=${pageNum}&userId=${id}`)
// 获取用户秒杀成功的消息
export const ApiGetUserSuccessById =(pageNum:number,userId:number)=>http.get(`/api/v1/record/getSuccess?pageIndex=${pageNum}&userId=${userId}`)
// 产品管理
// 获取所有商品列表商品
export const ApiGoodsList = (pageNum:number) => http.get(`/api/v1/good/getGoodList?pageNum=${pageNum}`)
// 根据id获取商品其他信息
export const ApiGoodsDetail = (id:number)=>http.get(`/api/v1/good/getGoodDetail?goodId=${id}`)
// 删除商品
export const ApiGoodsDelete = (goodsId:number|Array<number>)=>http.request('DELETE',`/api/v1/good/deleteGood?goodId=${goodsId}`)
// 编辑商品
export const ApiGoodsEdit = (goodsdata:any)=>http.request('PUT','/api/v1/good/editGood',goodsdata)
// 增加商品
export const ApiGoodsAdd = (goodsdata:any)=>http.post('/api/v1/good/addGood',goodsdata)
// 搜索商品
export const ApiGoodsSearch = (name:any)=>http.get(`/api/v1/good/search?pageIndex=1&keyword=${name}'`)
// 活动管理
// 获取所有活动信息
export const ApiGetActivityList = (pageNum:number)=>http.get(`/api/v1/activity/activityList?pageNum=${pageNum}`)
// 删除信息
export const ApiDeleteActivity = (id:number)=>http.request('DELETE',`/api/v1/activity/deleteActivity?activityId=${id}`)
// 编辑活动信息
export const ApiEditActivity = (data:any)=>http.request('PUT','/api/v1/activity/editActivity',data)
// 添加所有活动的信息
export const ApiAddActivity = (data:any)=>http.post('/api/v1/activity/addActivity',data)
// 获取活动配置时可选规则列表
export const ApiGetRulesList = ()=>http.get('/api/v1/activity/getRuleList')
// 设置某一活动的准入规则
export const ApiPutActivityRule = (data:any)=>http.request('PUT','/api/v1/activity/changeRule',data)
// 推送活动 
export const ApiPushActivity = (id:number)=>http.request('PUT',`/api/v1/activity/push?activityId=${id}`)
// 取消推送
export const ApiCancelActivity = (id:number)=>http.request('PUT',`/api/v1/activity/pull?activityId=${id}`)
// 根据id加载某个活动详情
export const ApiGetActivityDetail = (id:number)=>http.get(`/api/v1/activity/getActivityDetail?activityId=${id}`)
// 根据活动id查询申请记录
export const ApiBookRecords = (pageNum:number,id:number)=>http.get(`/api/v1/record/getByActivityId?pageIndex=${pageNum}&activityId=${id}`)
// 准入规则
export const ApiGetRiskRules = ()=>http.get('/api/v1/risk/all')
// 规则修改
export const ApiEditRiskRule = (data:any)=>http.request('PUT','/api/v1/risk/edit',data)
// 增加规则
export const ApiAddRiskRule = (data:any)=>http.post('/api/v1/risk/add',data)

// 申请记录
export const ApiGetAllBookRecord = (pageNum:number)=>http.get(`/api/v1/record/all?pageNum=${pageNum}`)
// 申请记录搜索
export const ApiRecordSearch = (name:string)=>http.get(`/api/v1/record/search?pageIndex=1&keyword=${name}`)
// 订单管理
export const ApiGetOrderList = (pageNum:number)=>http.get(`/api/v1/order/getOrderList?pageNum=${pageNum}`)
// 根据用户id和活动id查看用户的订单信息
export const ApiGetOrderUserandAcvityApply =(userId:number,activityId:number)=>http.get(`/api/v1/order/getOrderByUserIdAndActivityId?userId=${userId}&activityId=${activityId}`)

// 客户视角
// 秒杀页面活动列表
export const ApiGetShopsList = (pageNum:number)=>http.get(`/api/v1/activity/getActivityList?pageNum=${pageNum}`)
// 用户获取活动详情
export const ApiGetShopActivityDetail = (id:number)=>http.get(`/api/v1/activity/getActivityDetailByUser?activityId=${id}`)
// 获取商品详情
export const ApiGetShopGoodByUser = (id:number)=>http.get(`/api/v1/good/getGoodDetailByUser?goodId=${id}`)
// 用户申请活动
export const ApiGetShopApplyActivity = (id:number)=>http.get(`/api/v1/activity/applyActivity?activityId=${id}`)
// 用户申请的列表
export const ApiGetShopMyApplyList = ()=>http.get(`/api/v1/activity/getMyApproveList?pageIndex=1`)
// 用户点击秒杀后
export const ApiGetShopKillPath = (activityId:number)=>http.get(`/api/v1/spike/getPath?activityId=${activityId}`)
// 用秒杀返回的data中的值做秒杀接口获取订单
export const ApiGetShopBuyInfo = (path:string,activityId:number)=>http.get(`/api/v1/spike/buy/${path}?activityId=${activityId}`)
//付款后，如果在排队，就调用下面的成功按钮ApiGetShopSuccessOrder
export const ApiGetShopPay = (payId:number,activityId:number)=>http.get(`/api/v1/spike/pay?orderId=${payId}&activityId=${activityId}`)
// 40008就一直在排队
export const ApiGetShopSuccessOrder = (activityId:number)=>http.get(`/api/v1/spike/result?activityId=${activityId}`)
// 用户查看自己的订单
export const ApiGetShopMyOrder = (pageNum:number)=>http.get(`/api/v1/order/myOrder?pageIndex=${pageNum}`)
// 用户查看自己秒杀的订单
export const ApiGetMyKillList = (pageNum:number)=>http.get(`/api/v1/record/myRecord?pageIndex=${pageNum}`)










